﻿package com.wly
{	
	import com.wly.interval.IntervalManager;
	import com.wly.ui.common.EffectLayer;
	import com.wly.ui.common.GlobalInfo;
	import com.wly.ui.gamescene.GameScene;
	import com.wly.ui.scene.SceneManager;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	public class GameMain extends Sprite
	{
		private var _gameScene:GameScene;
		private var _sceneManager:SceneManager;
		
		public function GameMain()
		{
			super();
			
			if(stage)
			{
				init();
			}
			else
			{
				addEventListener(Event.ADDED_TO_STAGE, init);
			}
		} 
		
		private function init(e:Event=null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);			
			GlobalInfo.fullWidth  = stage.stageWidth;
			GlobalInfo.fullHeight = stage.stageHeight;
			
			addEventListener(Event.ENTER_FRAME, IntervalManager.getInstance().onFrame);
			
			_sceneManager = new SceneManager();
			addChild(_sceneManager);
			_sceneManager.init();
			
			addChild(EffectLayer.getIntance());
		}
	}
}